CXXTARGETS = counting-zero-pairs climbing-worm minimum-number-of-coins fractional-knapsack dijkstra \
             cspj-2023-apple cspj-2023-apple-optimized cspj-2023-apple-simplest cspj-2023-road cspj-2023-uqe cspj-2023-bus-bfs-initial cspj-2023-bus-bfs-final cspj-2023-bus-dfs cspj-2023-bus-dijkstra
CTARGETS=

CFLAGS = -Wall -Wextra -Werror -g -std=c99
CXXFLAGS = -Wall -Wextra -g -std=c++14

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
    CXXFLAGS += -DLINUX
endif
ifeq ($(UNAME_S), Darwin)
    CXXFLAGS += -DDARWIN
endif

ifeq ($(CXX), g++)
    CXXFLAGS += -fmax-errors=10
else ifeq ($(CXX), clang++)
    CXXFLAGS += -ferror-limit=10
endif

all:$(CXXTARGETS) $(CTARGETS)

$(CXXTARGETS):%:%.o
	$(CXX) -o $@ $<

$(CTARGETS):%:%.o
	$(CC) -o $@ $<

%.o:%.cpp
	$(CXX) -c $(CXXFLAGS) $< -o $@

%.o:%.c
	$(CC) -c $(CFLAGS) $< -o $@

.PHONY: clean

clean:
	rm -f *.o $(CXXTARGETS) $(CTARGETS)
